home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Mailcheck Source / drvr src / mmc_core.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-15  |  4.3 KB  |  140 lines  |  [TEXT/KAHL]

  1. /*
  2.  * interface to mac mail check core routines
  3.  * by Aaron Wohl (aw0g+@andrew.cmu.edu) jul 1990
  4.  * Carnegie-Mellon University
  5.  * Special Projects
  6.  * Pittsburgh, PA 15213-3890
  7.  * (412)-268-5032
  8.  */
  9.  
  10.  
  11. #define TICKS (1L)
  12. #define SECS  (60*TICKS)    /*one second is this many ticks*/
  13. #define MINS (60*SECS)
  14. #define HOURS (60*MINS)
  15.  
  16. #define DEFAULT_REMIND_TIME (15*MINS)
  17.  
  18. #define MMC_uname_len (12)    /*c string, first char is null if a user is not active*/
  19.  
  20. #define MMC_ST_maj_ver (15)
  21. #define MMC_ST_min_ver (14)
  22.  
  23. #define imax(xx_arg1,xx_arg2) (((xx_arg1)>(xx_arg2))?(xx_arg1):(xx_arg2))
  24. #define imin(xx_arg1,xx_arg2) (((xx_arg1)<(xx_arg2))?(xx_arg1):(xx_arg2))
  25.  
  26. #define MMC_check_num (0x12E4572AL)
  27.  
  28. /*
  29.  * flags with [R] are read only and can not be set with
  30.  * MCC_set_state
  31.  * The other flags can be changed by MCC_stat_state.
  32.  * the driver will also update them itself
  33.  *
  34.  * if MCS_u0 or MCS_u1 is set but its corrisponding string is not
  35.  * then driver will turn it off
  36.  */
  37. #define BIT(xx_arg) (1L<<((xx_arg)-1))
  38.  
  39. #define MCS_snooze    BIT(1)        /*hit snooze button*/
  40. #define MCS_error      BIT(2)        /*some kind of error is present*/
  41. #define MCS_want_open BIT(3)        /*would like to be open*/
  42. #define MCS_hearmm    BIT(5)        /*listen to mac mail when it sets the username*/
  43. #define MCS_io_pending BIT(8)        /*[R]an async IO call is pending*/
  44. #define MCS_debug     BIT(9)        /*[R]an async IO call is pending*/
  45.  
  46. #define MCS_unsaveable (MCS_debug|MCS_io_pending|MCS_snooze)
  47. /*
  48.  * how to notify
  49.  */
  50. #define MCS_nsound       BIT(12)
  51. #define MCS_nblink       BIT(13)
  52. #define MCS_npost     BIT(14)
  53. #define MCS_nhow      (MCS_nsound|MCS_nblink|MCS_npost)
  54.  
  55. /*
  56.  * snooze is setable but only via setmmuser
  57.  */
  58. #define MCS_setable \
  59.     (MCS_debug|MCS_want_open|MCS_hearmm|MCS_nhow)
  60.  
  61. #define TURN_OFF_FLAGS(xx_where,xx_fl) do {(xx_where).mmc_st&= ~(xx_fl);} while(0)
  62. #define TURN_ON_FLAGS(xx_where,xx_fl) do {(xx_where).mmc_st|=(xx_fl);} while(0)
  63. #define FLSET(xx_where,xx_fl) ((((xx_where).mmc_st)&(xx_fl))!=0)
  64.  
  65. #define MMC_MAX_STR (255)        /*largest string to return*/
  66.  
  67. #define DEFAULT_SOUND_ID (1) /*resource id of the default sound*/
  68.  
  69. /*
  70.  * published state
  71.  */
  72. struct mmc_state_R {
  73.     short mmc_st_maj_ver;        /*major version number*/
  74.     short mmc_st_min_ver;        /*major version number*/
  75.     short mmc_sound_id;            /*resource id of sound to play*/
  76.     short mmc_last_err_syserr;    /*error code of last error*/
  77.     short mmc_last_err_kind;    /*MCE_ code*/
  78.     long mmc_st;                /*MCS_ state flags*/
  79.     long mmc_remind_time;        /*how often to remind users of mail*/
  80.     char mmc_uname[MMC_uname_len];    /*usernames to check for, c strings*/
  81.     char mmc_text_state[MMC_MAX_STR]; /*current state*/    
  82.     long mmc_check_num;            /*for CDEV to stash its version info*/
  83. };
  84. typedef struct mmc_state_R mmc_state,*mmc_state_pt;
  85.  
  86. /*
  87.  * io manager control parameter block to pass to Control
  88.  */
  89. struct mmc_io_record_R {
  90.     void        *qLink;
  91.     short        qType;
  92.     short        ioTrap;
  93.     void        *ioCmdAddr;
  94.     void        *ioCompletion;
  95.     short        ioResult;
  96.     void        *ioNamePtr;
  97.     short        ioVRefNum;
  98.     short        ioCRefNum;
  99.     short        csCode;
  100.     void *        private_state;    /*returned with pointer to mmc private vars*/    
  101.     mmc_state    iostate;    /*state to set, current state returned*/
  102. };
  103. typedef struct mmc_io_record_R mmc_io_record,*mmc_io_record_pt;
  104.  
  105. #define MMC_goodbye      (-1)    /*goodbye kiss, the heap is about to be initilized*/
  106.                      /*  0      unused*/
  107. #define    MMC_killio        1    /*killio does this control entry to stop io*/
  108. #define MMC_get_state   2   /*read current driver state*/
  109. #define MMC_set_state   3   /*set current driver state*/
  110. #define MMC_setmmuser   4   /*set macmail user*/
  111.  
  112. #define MMC_run           65    /*run periodic functions*/
  113.  
  114. #define MCE_ISERR        0x020
  115.  
  116. #define MCE_NOERRR        0    /*no error presend*/
  117. #define MCE_UDP_REL        1    /*udp release failed*/
  118. #define MCE_TOO_OLD        2    /*driver to old to talk to server*/
  119. #define MCE_UDP_READ    3    /*read failed*/
  120. #define MCE_UDP_CREATE  4    /*upd create failed*/
  121. #define MCE_MACTCP        5   /*mactcp open failed*/
  122. #define MCE_UDP_WRITE    6    /*udp write failed*/
  123. #define MCE_REM_ERR        7    /*remote error froms server*/
  124. #define MCE_TIMEOUT        8    /*no response from server*/
  125.  
  126. /*
  127.  * localy define a procedure with a prototype
  128.  */
  129. #define LDEF(xx_arg) static xx_arg; static xx_arg
  130.  
  131. /*
  132.  * initialize a parameter block for a control coll
  133.  */
  134. #define INIT_CPB(xx_pb,xx_ref,xx_cscode) \
  135.   do {(xx_pb).ioCompletion=0; \
  136.    (xx_pb).ioVRefNum=0; \
  137.    (xx_pb).ioCRefNum=(xx_ref); \
  138.    (xx_pb).csCode=(xx_cscode); \
  139.   } while(0)
  140.